const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Route = sequelize.define('Route', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  origin: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '起点'
  },
  destination: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '终点'
  },
  strategy: {
    type: DataTypes.INTEGER,
    allowNull: true,
    defaultValue: 0,
    comment: '路径策略'
  },
  waypoints: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '途经点（JSON格式）'
  },
  distance: {
    type: DataTypes.INTEGER,
    allowNull: true,
    comment: '总距离（米）'
  },
  duration: {
    type: DataTypes.INTEGER,
    allowNull: true,
    comment: '预计时间（秒）'
  },
  tolls: {
    type: DataTypes.DECIMAL(10, 2),
    allowNull: true,
    comment: '收费（元）'
  },
  toll_distance: {
    type: DataTypes.INTEGER,
    allowNull: true,
    comment: '收费距离（米）'
  },
  steps: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '路径步骤（JSON格式）'
  },
  polyline: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '路径坐标（JSON格式）'
  },
  traffic_condition: {
    type: DataTypes.STRING(50),
    allowNull: true,
    comment: '交通状况'
  }
}, {
  tableName: 'route',
  comment: '路线规划表'
});

module.exports = Route; 